<#include '/admin/header.html' >
<#assign dateFormat="com.enation.framework.directive.DateformateDirective"?new()>
<style>
td .layui-btn-small{
background:#1E9FFF;
}
</style>
<div  class="admin-main">
   <div>
        <!--提示区域  -->
        <div class="page_explain">
            <h2>操作提示</h2>
            <ul>
			    <li><span>.</span>注意：快递单模板的预览以及打印，请在WIN系统并且IE浏览器中使用。</li>
                <li><span>.</span>系统中内置宅急送和圆通速递模板，如果需要其他快递模板，请自行进行添加设计。</li>
				<li><span>.</span>快递模板设置完之后，请到“订单”-“待发货订单”中，勾选要打印的订单，点击“打印快递单”进行打印。</li>
				<li><span>.</span>快递单模板的好处：使用同一个快递的商品，就可以按照我们设计的快递单样式进行批量打印，而不需要进行繁琐的设置。</li>
            </ul>
        </div>
        <!--按钮操作  -->
        <div class="table_control">
            <div class="table_opera">
                <button type="button" class="layui-btn layui-btn-primary " title="添加" onclick="newTab('添加模板','${ctx}/shop/admin/print-tmpl//add.do')"><i class="icon iconfont icon-llalbumshopselectorcreate"></i></button>
                <button type="button" class="layui-btn layui-btn-primary " title="删除" onclick="del()" ><i class="icon iconfont icon-guanbi1"></i></button>
                <button type="button" class="layui-btn layui-btn-primary " title="提示" id="explain"><i class="icon iconfont icon-tishi1"></i></button>
            </div>
        </div>
    </div>
    
   <!--表格区域  -->
   <form id="prt_tmplform">
    <table id="prt_tmpldata" class="layui-table site-table table-hover" width="100%" lay-skin="line">
        <thead>
          <tr>
            <th><input type='checkbox'  class='btn-checkall fly-checkbox' id='selected-all'></th>
            <th>模板名称</th>
            <th>是否启用</th>
            <th>操作</th>
          </tr>
        </thead>
    </table>
    <!--传值等操作(暂定)  -->
    <div id="addBrand" ></div>
   </form>
</div>

<!--js区域  -->
<script>
$(function(){
	
	var table = $('#prt_tmpldata').DataTable({
		"language": {
	        "url": "${staticserver}/media/zh_CN.txt"
	    },
	    "processing": true,
	    "serverSide": true,
	    "ordering": false,
	    "searching": false,
	    "lengthChange": false,
	    ajax: {
	        //指定数据源
	        type:"post",
	        url: '${ctx}/shop/admin/print-tmpl/list-json.do',
	    },
	    columns: [ //定义列
            {"data": function (obj) {
                return '<input type="checkbox" name="id" class="fly-checkbox" value=' + obj.prt_tmpl_id + '>';
            		}},
	        {data: "prt_tmpl_title"},
	        {"data": function (obj) {
	    		if(obj.shortcut=="true"){
	    			return '是';
	    		}else{
	    			return '否';
	    		}
            }},
	        {data: null,"render": function(data, type, row) {
	        	return "<a class='layui-btn layui-btn-small _aa'  onclick=\"newTab('查看模板详细','${ctx}/shop/admin/print-tmpl//edit.do?prt_tmplId="+row.prt_tmpl_id+"')\">查看</a>";		
	       	}}
	     ]
	});
});

function del(){
	var obj = document.getElementsByName("id");
    var check_val = [];
    for(k in obj){
        if(obj[k].checked){
        	check_val.push(obj[k].value);   	
        }
   	}
    if(check_val.length==0){
    	alert("请至少选择一项");
    	return false;
    }
    if (!confirm("确认要删除吗？")) {
		return;
	}
	$.ajax({
		url: '${ctx}/shop/admin/print-tmpl/delete.do?prt_tmpl_id='+check_val,
		type : "POST",
		dataType : 'json',
		success : function(result) {
			if (result.result == 1) {
				$.Loading.success(result.message);
				location.reload();
			}
			if (result.result == 0) {
				$.Loading.error(result.message)
			}
		},
		error : function(e) {
			$.Loading.error("出现错误 ，请重试");
		}
	});
}
</script>
<#include '/admin/footer.html' >
